# _*_coding:utf-8 _*_
# @Time   :2020/6/26
import requests
from .config import getHeaders
import string, random


def accountConfirm(account, password):
    """
    验证 学号、身份证后六位  是否正确
    :param account: 学号
    :param password: 身份证后六位
    :return:正确 返回 True，错误 返回 False
    """
    data = {
        "username": account,
        "password": password
    }
    res = requests.get('http://smart.hnsyu.net/xyt/wx/index/loginSubmit.do',
                       params=data, headers=getHeaders())
    if res.text == 'fail':
        return False
    return True


def gencode(num=8):
    code = string.ascii_letters + string.digits
    return ''.join(random.choices(code, k=num))
